import { request } from '../../request/index.js';
import { wxLogin } from '../../utils/asyncWx'
Page({
  async handlegetUserInfo(e) {
    try {
      //获取用户信息
      const {encryptedData,rawData,iv,signature} = e.detail;
      //获取小程序登录成功后的code
      const {code} = await wxLogin();
      //发送请求，获取token
      const loginParams = {encryptedData,rawData,iv,signature,code};
      const {token} = await request({url:'/users/wxlogin',data:loginParams,method:'post'});
      //将token寸入缓存
      // wx.setStorageSync('token', token);
      //跳转页面
      wx.navigateBack({
        delta: 1,
    })
    } catch (error) {
      console.log(error)
    }
  }
})